package GUI;

import Controle.Controle;
import ElementosLogicos.Estado;
import Funcionalidade.GR2AF;
import Modelo.AutomatoFinito;
import Modelo.GramaticaRegular;

public class main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try {

			Controle c = new Controle();

			/** Teste ER */
			// c.gerarER("abc", "(a|b)*c+");
			// c.editarER(1455903977, "(ab)*c?");

			/** Teste GR */
			 GramaticaRegular g;// = new GramaticaRegular("abc", "SAB");
			 g = c.gerarGR("abc", "SAB");
			 c.addProducaoGR(g, "S -> aA | bA");
			 c.addProducaoGR(g, "A -> bB | aA");
			 c.addProducaoGR(g, "B -> cS | a");
			 System.out.println(g.toString());
			 System.out.println();
			 c.editarProducaoGR(g, "B -> cS | c", 2);
			 System.out.println(g.toString());

			/** Teste AF */
			 AutomatoFinito af;// = new AutomatoFinito("abc");
			 af = c.gerarAF("abc");
			 Estado q0 = c.geraEstadoAF(af, "q0");
			 Estado q1 = c.geraEstadoAF(af, "q1");
			 
			 //System.err.println("antes "+q0.toString());
			 
			 c.geraTransicaoAF(q0, 'a', q1);
			 c.geraTransicaoAF(q0, 'b', q0);
			 c.geraTransicaoAF(q1, 'a', q1);
			 c.geraTransicaoAF(q1, 'b', q0);

			 c.addEstadoAF(af, q0);
			 c.addEstadoAF(af, q1);
			
			 System.out.println(af.toString());
			 
			 //System.err.println("depois "+q0.toString());

			

		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println("--------");
			e.printStackTrace();
			//System.err.println("ERROR!");
		}

	}

}
